#include<iostream>
using namespace std;

 namespace zjw {
	 template<class T>
	 class vector{
	 public:
		 vector()
			 :begin(nullptr),
			 finish(nullptr),
			 end_stroage(nullptr)
			  
		 {
		 
		 
		 
		 
		 
		 
		 
		 
		 }
         typedef T* iterator;

	     
		 iterator Begin()
		 {
		 
		 
			 return begin;
		 
		 
		 
		 }
		 iterator End()
		 {


			 return finish;



		 }
		 int size()
		 {


			 return finish - begin;



		 }
		 int capacity()
		 {
		 
			 return end_stroage - begin;
		 
		 }
		 bool empty()
		 {
		 
			 return begin == finish;
		
		 }
		 int operator[](size_t pos)
		 {
			 assert(pos < size);
			 return  begin[pos];
		 
		 }

		 void reserve(int n)
		 {
			 if (n > capacity())
			 {
				 int sz = size();
				 T* tmp = new T[n];
				 if (begin)
				 {
					 memcpy(tmp, begin,sizeof(T)*size());
					 delete[] begin;


				 }
				 //int size = size();
			    
				 begin = tmp;
				 finish = begin+sz ;
				 end_stroage = begin + n;
			 }
		
		 
		 }
		 void push_back(const T x)
		 {
		 
			 if (finish == end_stroage)
			 {
				 reserve(capacity() == 0 ? 4 : capacity() * 2);


			 }
		 
			  *finish = x;
			  finish++;
		 
		 }
		 void pop_back()
		 {
		 
			 assert(!empty());
             finish--;
		 
		 }
		 void resize(size_t n,T val=T())
		 {
		   
			 if (n < size())
			 {

				 finish = begin + n;


			 }
			 else
			 {
				 if (n > capacity())
					 reserve(n);
				 while (finish != begin + n)
				 {
					 *finish = val;
					 ++finish;
				 }
			 
			 
			 
	
			 }
		 
		 
		 
		 
		 
		 }





	// private:
	 public:
		 iterator begin;
		 iterator finish;
		 iterator end_stroage;
	 
	 };

};
 int main()
 {
	 zjw::vector<int>st;
	 st.push_back(1);
	 st.push_back(2);
	 st.push_back(3);
	
	 st.push_back(4);
	 st.push_back(5);
	 cout << st.size() << endl;
	 cout << st.capacity() << endl;

	 st.reserve(10);
	 cout << st.size() << endl;
	 cout << st.capacity() << endl;
	 zjw::vector<int>::iterator it = st.Begin();
	 cout << st.Begin() << endl;
	 cout << st.End() << endl;
	 cout << st.End() - st.Begin() << endl;
	 cout << st.finish << endl;
	 
	 while (it != st.End())
	 {

		 cout << *it << " ";
		 it++;
	 }

 
 }